//
//  FQDRegisterNavViewController.m
//  FakeQDaily
//
//  Created by mewxiv on 9/21/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDRegisterNavViewController.h"
#import "FQDMobileRegisterViewController.h"
#import "UIView+FQDExtension.h"
#import "UIImage+ImageEffects.h"

@interface FQDRegisterNavViewController ()

@property (nonatomic, strong) FQDMobileRegisterViewController *mobileRegisterVC;

@end

@implementation FQDRegisterNavViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self commonInit];
    }
    return self;
}

- (void)commonInit
{
    [self setNavigationBarHidden:YES animated:NO];
    
    _mobileRegisterVC = [[FQDMobileRegisterViewController alloc] init];
    self.viewControllers = @[_mobileRegisterVC];
}

- (void)setBackgroundViewController:(UIViewController *)backgroundViewController
{
    _backgroundViewController = backgroundViewController;
    
    WeakSelf;
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        UIImage *captureImage = [backgroundViewController.view captureViewHierarchy];
        UIImage *blurScreenShot = [captureImage blurImage];
        dispatch_async(dispatch_get_main_queue(), ^{
            weakSelf.mobileRegisterVC.blurBgImage = blurScreenShot;
        });
    });
}

@end
